Whitespace changes, mostly trailing whitespace.
You may find format_skeleton.c and filter_skeleton.c in the source tree
to be helpful examples. Just add meat!
-Prefer Qt objects/classes to ISO C/POSIX services. QStrings are reference
-counted, implicitly shared, and have a robust supporting library. QDateTime
-supports sub-second time and a range of dates far beyond 1970->2038 and are
-much more pleasant to work with than ctime/mktime/struct tm. "But I see
-strcpy, sprintf, and struct tm and such in the code!" It's true; GPSBabel
-is a tenured project of well over ten years. We have code that predates
-our move to C++/Qt that isn't well tested or has a low payoff to modernize
-and uses old constructs. Our actively maintained/strategic formats like
-GPX and KML tend to be better examples of modern programming, using things
-like XmlStreamWriter instead of fprintf and are generally better models to
-follow.
+Prefer Qt objects/classes to ISO C/POSIX services.
+ * QStrings are reference counted, implicitly shared, and have a
+ robust supporting library.
+ * QDateTime supports sub-second time and a range of dates far
+ beyond 1970->2038 and are much more pleasant to work with
+ than ctime/mktime/struct tm.
+ * QXmlStreamReader and Writer eliminate the need to explictly quote data.
+"But I see strcpy, sprintf, and struct tm and such in the code!" It's
+true; GPSBabel is a tenured project of well over ten years. We have
+code that predates our move to C++/Qt that isn't well tested or has a
+low payoff to modernize and uses old constructs. Our actively
+maintained/strategic formats like GPX and KML tend to be better
+examples of modern programming and are generally better models to
+follow. New code shouldn't be using xstrdup and gbfprintf.
Compilers complain for a reason. Code shouldn't emit warnings.
int
mumble(int whatever)
{
+ <2spaces>char* pointers_clump_to_type;
<2spaces>if (whatevever) {
<4spaces>return blah;
<2spaces>}
gbfprintf(file_out, "<head>\n");
gbfprintf(file_out, " <meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\">\n");
- // Don't write this line when running test suite. Actually, we should
+ // Don't write this line when running test suite. Actually, we should
// probably not write this line at all...
if (!getenv("GPSBABEL_FREEZE_TIME")) {
- gbfprintf(file_out, " <meta name=\"Generator\" content=\"GPSBabel %s\">\n", gpsbabel_version);
+ gbfprintf(file_out, " <meta name=\"Generator\" content=\"GPSBabel %s\">\n", gpsbabel_version);
}
gbfprintf(file_out, " <title>GPSBabel HTML Output</title>\n");
if (stylesheet) {
wpt = new Waypoint;
// Could probably find a way to eliminate the alloc/copy.
- char *s = xstrndup(w.name, sizeof(w.name));
+ char* s = xstrndup(w.name, sizeof(w.name));
wpt->shortname = s;
xfree(s);
rte = route_head_alloc();
route_add_head(rte);
// TODO: find a way to eliminate the copy.
- char *s = xstrndup(hrte.name, sizeof(hrte.name));
+ char* s = xstrndup(hrte.name, sizeof(hrte.name));
rte->rte_name = s;
xfree(s);
/* rte->rte_num = hrte.num + 1; only internal number */
track_add_head(trk);
// TODO: find a way to eliminate the copy.
- char *s = xstrndup(th.name, sizeof(th.name));
+ char* s = xstrndup(th.name, sizeof(th.name));
trk->rte_name = s;
xfree(s);
trk->rte_num = th.trk_num;
QString
mkshort(short_handle h, const QString& istring)
{
- char *t = mkshort(h, CSTR(istring));
+ char* t = mkshort(h, CSTR(istring));
QString r(t);
xfree(t);
return r;
xfree(data->name);
}
if ((data->type == wptdata) && (data->refct == 0)) {
- delete (Waypoint*)data->data;
+ delete(Waypoint*)data->data;
}
xfree(data);
}
mmo_data_t* data;
Waypoint* wpt2;
-// This code path isn't tested in anything we have and I have No Idea
+// This code path isn't tested in anything we have and I have No Idea
// what it was trying to do. Throw a hard error to force the hand of
// getting a sample file.
abort();
}
static void
-mmo_writestr(const QString& str) {
+mmo_writestr(const QString& str)
+{
// If UTF-8 is used instgead of Latin1, we fail in weird ways.
mmo_writestr(str.toLatin1().constData());
}
static void
mmo_write_wpt_cb(const Waypoint* wpt)
{
- QString str;
+ QString str;
QString cx;
int objid;
time_t time;
Copyright (c) 2014 Ralf Horstmann <ralf@ackstorm.de>
Copyright (C) 2014 Robert Lipe, robertlipe+source@gpsbabel.org
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
if (global_opts.debug_level > 1) {
qDebug() << "line: " << line;
- for (int i = 0; i < fields.size(); i++)
+ for (int i = 0; i < fields.size(); i++) {
qDebug() << "field" << i << fields.at(i);
+ }
}
// don't consider lines without latitude/longitude
- if (fields.size() <= fld_lat)
+ if (fields.size() <= fld_lat) {
return;
+ }
// only type 1 and type 5 lines contain coordinates
bool ok = false;
- int val_type = fields.at(fld_type).trimmed().toInt(&ok);
- if (!ok)
+ int val_type = fields.at(fld_type).trimmed().toInt(&ok);
+ if (!ok) {
return;
- if (val_type != 1 && val_type != 5)
+ }
+ if (val_type != 1 && val_type != 5) {
return;
+ }
// This field is not present in .trc files, only in .ftn, so
// ignore line if present and != 1
if (fields.size() > fld_gps_valid) {
int val_gps_valid = fields.at(fld_gps_valid).trimmed().toInt(&ok);
- if (!ok || val_gps_valid != 1)
+ if (!ok || val_gps_valid != 1) {
return;
+ }
}
double val_lon = fields.at(fld_lon).trimmed().toDouble(&ok) / 3600000.0;
- if (!ok)
+ if (!ok) {
return;
+ }
double val_lat = fields.at(fld_lat).trimmed().toDouble(&ok) / 3600000.0;
- if (!ok)
+ if (!ok) {
return;
+ }
Waypoint* wpt = new Waypoint;
wpt->latitude = val_lat;
if (fields.size() > fld_altitude) {
double val_alt = fields.at(fld_altitude).trimmed().toDouble(&ok);
- if (ok)
+ if (ok) {
wpt->altitude = val_alt;
+ }
}
if (fields.size() > fld_timestamp) {
int val_time = fields.at(fld_timestamp).trimmed().toInt(&ok);
- if (ok)
+ if (ok) {
wpt->SetCreationTime(val_time);
+ }
}
-
+
track_add_wpt(mynav_track, wpt);
}
gbfclose(fin);
}
-static void
+static void
mynav_rd(void)
{
QString buff;
waypt->hdop = ((unsigned char)buffer[0]) * 0.2f;
waypt->sat = buffer[1];
- waypt->SetCreationTime(decode_sbp_datetime_packed(buffer + 4),
+ waypt->SetCreationTime(decode_sbp_datetime_packed(buffer + 4),
decode_sbp_msec(buffer + 2));
decode_sbp_position(buffer + 12, waypt);
WAYPT_SET(waypt, speed, le_read16(buffer + 24) * 0.01f);
rte->rte_name = str;
wpt->shortname = str;
- // The remaining cases only apply to the center node
+ // The remaining cases only apply to the center node
} else if ((ikey = osm_feature_ikey(key)) >= 0) {
wpt->icon_descr = osm_feature_symbol(ikey, CSTR(value));
} else if (key == "note") {
static struct blockheader*
compute_blocks(struct hdr* start, int count,
- double minlon, double maxlon, double minlat, double maxlat) {
+ double minlon, double maxlon, double minlat, double maxlat)
+{
struct blockheader* newblock;
newblock = (struct blockheader*)xcalloc(sizeof(*newblock), 1);
if (current_target == 'T') {
current_trk = route_head_alloc();
track_add_head(current_trk);
- if (!rte->rte_name.isEmpty()) {
+ if (!rte->rte_name.isEmpty()) {
current_trk->rte_desc = QString("Generated from route %1").arg(rte->rte_name);
current_trk->rte_name = rte->rte_name; /* name the new trk */
}
int res = 0;
const QString kBase35 = "0123456789ABCDEFGHJKMNPQRTVWXYZ"; // ILOSU are omitted.
if (str.startsWith("GC")) {
- int base35 = str.size() > 6; // above GCFFFF?
+ int base35 = str.size() > 6; // above GCFFFF?
QString s = str.mid(2);
while (!s.isEmpty()) {
res = res * 16 + kBase35.indexOf(s[0]);
str == "0") {
return status_false;
}
-return status_unknown;
+ return status_unknown;
}
static QDateTime
double swiss_easting = unicsv_unknown;
double swiss_northing = unicsv_unknown;
int checked = 0;
- time_t date = -1;
+ time_t date = -1;
time_t time = -1;
int usec = -1;
char is_localtime = 0;
va_list args;
int res;
va_start(args, fmt);
- char *cstrp;
+ char* cstrp;
res = xvasprintf(&cstrp, fmt, args);
*strp = cstrp;
xfree(cstrp);
if (*m == '\0') {
return 0; /* incomplete escape sequence */
}
- /* pass-through next character */
+ /* pass-through next character */
default:
if (*m != *s) {
result += t->tm_min;
result *= 60;
result += t->tm_sec;
- return(result);
+ return (result);
}
/*
static const QChar Z('Z');
QString r = s;
int i = r.length();
- while(i--) {
+ while (i--) {
QChar letter = r[i].toUpper();
if (letter >= A && letter <= M) {
r[i] = QChar(r[i].toLatin1() + 13);
{
#if 0
// If we were willing to link core against QtGui (not out of the question)
- // we could just do...and either decide whether to add handling for [IMG]
+ // we could just do...and either decide whether to add handling for [IMG]
// or just say we don't do that any more.
QTextDocument doc;
- doc.setHtml( in->utfstring );
+ doc.setHtml(in->utfstring);
return xstrdup(CSTR(doc.toPlainText().simplified()));
#else
char* outstring, *out;
}
if ((wpt->latitude < -90) || (wpt->latitude > 90.0))
- Fatal() << wpt->session->name
- << "Invalid latitude" << lat_orig << "in waypoint"
+ Fatal() << wpt->session->name
+ << "Invalid latitude" << lat_orig << "in waypoint"
<< wpt->shortname;
if ((wpt->longitude < -180) || (wpt->longitude > 180.0))
- Fatal() << "Invalid longitude" << lon_orig << "in waypoint"
+ Fatal() << "Invalid longitude" << lon_orig << "in waypoint"
<< wpt->shortname;
/*